<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
      <title>Class XmlUtil | HiAPI-C# 2025 </title>
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <meta name="title" content="Class XmlUtil | HiAPI-C# 2025 ">
      
      <meta name="description" content="Utility for managing XML.">
      <link rel="icon" href="../img/HiAPI.favicon.ico">
      <link rel="stylesheet" href="../public/docfx.min.css">
      <link rel="stylesheet" href="../public/main.css">
      <meta name="docfx:navrel" content="../toc.html">
      <meta name="docfx:tocrel" content="toc.html">
      
      <meta name="docfx:rel" content="../">
      
      
      
      <meta name="loc:inThisArticle" content="In this article">
      <meta name="loc:searchResultsCount" content="{count} results for &quot;{query}&quot;">
      <meta name="loc:searchNoResults" content="No results for &quot;{query}&quot;">
      <meta name="loc:tocFilter" content="Filter by title">
      <meta name="loc:nextArticle" content="Next">
      <meta name="loc:prevArticle" content="Previous">
      <meta name="loc:themeLight" content="Light">
      <meta name="loc:themeDark" content="Dark">
      <meta name="loc:themeAuto" content="Auto">
      <meta name="loc:changeTheme" content="Change theme">
      <meta name="loc:copy" content="Copy">
      <meta name="loc:downloadPdf" content="Download PDF">

      <script type="module" src="./../public/docfx.min.js"></script>

      <script>
        const theme = localStorage.getItem('theme') || 'auto'
        document.documentElement.setAttribute('data-bs-theme', theme === 'auto' ? (window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light') : theme)
      </script>

  </head>

  <body class="tex2jax_ignore" data-layout="" data-yaml-mime="ManagedReference">
    <header class="bg-body border-bottom">
      <nav id="autocollapse" class="navbar navbar-expand-md" role="navigation">
        <div class="container-xxl flex-nowrap">
          <a class="navbar-brand" href="../index.html">
            <img id="logo" class="svg" src="../img/HiAPI.logo.png" alt="">
            
          </a>
          <button class="btn btn-lg d-md-none border-0" type="button" data-bs-toggle="collapse" data-bs-target="#navpanel" aria-controls="navpanel" aria-expanded="false" aria-label="Toggle navigation">
            <i class="bi bi-three-dots"></i>
          </button>
          <div class="collapse navbar-collapse" id="navpanel">
            <div id="navbar">
              <form class="search" role="search" id="search">
                <i class="bi bi-search"></i>
                <input class="form-control" id="search-query" type="search" disabled placeholder="Search" autocomplete="off" aria-label="Search">
              </form>
            </div>
          </div>
        </div>
      </nav>
    </header>

    <main class="container-xxl">
      <div class="toc-offcanvas">
        <div class="offcanvas-md offcanvas-start" tabindex="-1" id="tocOffcanvas" aria-labelledby="tocOffcanvasLabel">
          <div class="offcanvas-header">
            <h5 class="offcanvas-title" id="tocOffcanvasLabel">Table of Contents</h5>
            <button type="button" class="btn-close" data-bs-dismiss="offcanvas" data-bs-target="#tocOffcanvas" aria-label="Close"></button>
          </div>
          <div class="offcanvas-body">
            <nav class="toc" id="toc"></nav>
          </div>
        </div>
      </div>

      <div class="content">
        <div class="actionbar">
          <button class="btn btn-lg border-0 d-md-none" type="button" data-bs-toggle="offcanvas" data-bs-target="#tocOffcanvas" aria-controls="tocOffcanvas" aria-expanded="false" aria-label="Show table of contents">
            <i class="bi bi-list"></i>
          </button>

          <nav id="breadcrumb"></nav>
        </div>

        <article data-uid="Hi.Common.XmlUtils.XmlUtil">



  <h1 id="Hi_Common_XmlUtils_XmlUtil" data-uid="Hi.Common.XmlUtils.XmlUtil" class="text-break">
Class XmlUtil  
  </h1>

  <div class="facts text-secondary">
    <dl><dt>Namespace</dt><dd><a class="xref" href="Hi.html">Hi</a>.<a class="xref" href="Hi.Common.html">Common</a>.<a class="xref" href="Hi.Common.XmlUtils.html">XmlUtils</a></dd></dl>
  <dl><dt>Assembly</dt><dd>HiGeom.dll</dd></dl>
  </div>

  <div class="markdown summary"><p>Utility for managing XML.</p>
</div>
  <div class="markdown conceptual"></div>

  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public static class XmlUtil</code></pre>
  </div>




  <dl class="typelist inheritance">
    <dt>Inheritance</dt>
    <dd>
      <div><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object">object</a></div>
      <div><span class="xref">XmlUtil</span></div>
    </dd>
  </dl>



  <dl class="typelist inheritedMembers">
    <dt>Inherited Members</dt>
    <dd>
    <div>
      <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object)">object.Equals(object)</a>
    </div>
    <div>
      <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object-system-object)">object.Equals(object, object)</a>
    </div>
    <div>
      <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.gethashcode">object.GetHashCode()</a>
    </div>
    <div>
      <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.gettype">object.GetType()</a>
    </div>
    <div>
      <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone">object.MemberwiseClone()</a>
    </div>
    <div>
      <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.referenceequals">object.ReferenceEquals(object, object)</a>
    </div>
    <div>
      <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.tostring">object.ToString()</a>
    </div>
  </dd></dl>






  <h2 class="section" id="fields">Fields
</h2>



  <h3 id="Hi_Common_XmlUtils_XmlUtil_FileXName" data-uid="Hi.Common.XmlUtils.XmlUtil.FileXName">
  FileXName
  
  </h3>

  <div class="markdown level1 summary"><p>Alias for XmlFileXName, used for backward compatibility.</p>
</div>
  <div class="markdown level1 conceptual"></div>

  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public const string FileXName = &quot;XmlSource&quot;</code></pre>
  </div>




  <h4 class="section">Field Value</h4>
  <dl class="parameters">
    <dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
    <dd></dd>
  </dl>










  <h3 id="Hi_Common_XmlUtils_XmlUtil_SelfHostName" data-uid="Hi.Common.XmlUtils.XmlUtil.SelfHostName">
  SelfHostName
  
  </h3>

  <div class="markdown level1 summary"><p>Constant representing self-hosted XML content. Used for legacy compatibility.</p>
</div>
  <div class="markdown level1 conceptual"></div>

  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public const string SelfHostName = &quot;SelfHost&quot;</code></pre>
  </div>




  <h4 class="section">Field Value</h4>
  <dl class="parameters">
    <dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
    <dd></dd>
  </dl>










  <h3 id="Hi_Common_XmlUtils_XmlUtil_XmlFileXName" data-uid="Hi.Common.XmlUtils.XmlUtil.XmlFileXName">
  XmlFileXName
  
  </h3>

  <div class="markdown level1 summary"><p>The XML element name used for file references.</p>
</div>
  <div class="markdown level1 conceptual"></div>

  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public const string XmlFileXName = &quot;XmlSource&quot;</code></pre>
  </div>




  <h4 class="section">Field Value</h4>
  <dl class="parameters">
    <dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
    <dd></dd>
  </dl>









  <h2 class="section" id="methods">Methods
</h2>


  <a id="Hi_Common_XmlUtils_XmlUtil_GetDictionaryByXmlSource_" data-uid="Hi.Common.XmlUtils.XmlUtil.GetDictionaryByXmlSource*"></a>

  <h3 id="Hi_Common_XmlUtils_XmlUtil_GetDictionaryByXmlSource__1_System_Xml_Linq_XElement_System_String_Hi_Common_XmlUtils_GenMode_" data-uid="Hi.Common.XmlUtils.XmlUtil.GetDictionaryByXmlSource``1(System.Xml.Linq.XElement,System.String,Hi.Common.XmlUtils.GenMode)">
  GetDictionaryByXmlSource&lt;T&gt;(XElement, string, GenMode)
  
  </h3>

  <div class="markdown level1 summary"><p>Deserializes a dictionary of objects from an XML element.</p>
</div>
  <div class="markdown level1 conceptual"></div>

  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public static Dictionary&lt;string, T&gt; GetDictionaryByXmlSource&lt;T&gt;(this XElement src, string baseDirectory, GenMode genMode) where T : class</code></pre>
  </div>

  <h4 class="section">Parameters</h4>
  <dl class="parameters">
    <dt><code>src</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.xml.linq.xelement">XElement</a></dt>
    <dd><p>The source XML element containing the serialized dictionary</p>
</dd>
    <dt><code>baseDirectory</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
    <dd><p>The base directory for resolving paths</p>
</dd>
    <dt><code>genMode</code> <a class="xref" href="Hi.Common.XmlUtils.GenMode.html">GenMode</a></dt>
    <dd><p>The generation mode to use for deserialization</p>
</dd>
  </dl>

  <h4 class="section">Returns</h4>
  <dl class="parameters">
    <dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.collections.generic.dictionary-2">Dictionary</a>&lt;<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a>, T&gt;</dt>
    <dd><p>A dictionary containing the deserialized objects</p>
</dd>
  </dl>

  <h4 class="section">Type Parameters</h4>
  <dl class="parameters">
    <dt><code>T</code></dt>
    <dd><p>The type of objects to deserialize into the dictionary</p>
</dd>
  </dl>










  <a id="Hi_Common_XmlUtils_XmlUtil_GetFileUnwrappedXElement_" data-uid="Hi.Common.XmlUtils.XmlUtil.GetFileUnwrappedXElement*"></a>

  <h3 id="Hi_Common_XmlUtils_XmlUtil_GetFileUnwrappedXElement_System_Xml_Linq_XElement_System_String_System_String__" data-uid="Hi.Common.XmlUtils.XmlUtil.GetFileUnwrappedXElement(System.Xml.Linq.XElement,System.String,System.String@)">
  GetFileUnwrappedXElement(XElement, string, out string)
  
  </h3>

  <div class="markdown level1 summary"><p>Unwraps a file reference XML element to load its actual content.</p>
</div>
  <div class="markdown level1 conceptual"></div>

  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public static XElement GetFileUnwrappedXElement(this XElement src, string baseDirectory, out string relFile)</code></pre>
  </div>

  <h4 class="section">Parameters</h4>
  <dl class="parameters">
    <dt><code>src</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.xml.linq.xelement">XElement</a></dt>
    <dd><p>The source XML element that may be a file reference</p>
</dd>
    <dt><code>baseDirectory</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
    <dd><p>The base directory for resolving paths</p>
</dd>
    <dt><code>relFile</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
    <dd><p>Output parameter that receives the relative file path if src is a file reference, or null otherwise</p>
</dd>
  </dl>

  <h4 class="section">Returns</h4>
  <dl class="parameters">
    <dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.xml.linq.xelement">XElement</a></dt>
    <dd><p>If src is a file reference element, returns the XML content loaded from the referenced file;
otherwise, returns the original element</p>
</dd>
  </dl>











  <a id="Hi_Common_XmlUtils_XmlUtil_GetFileWrappedXElement_" data-uid="Hi.Common.XmlUtils.XmlUtil.GetFileWrappedXElement*"></a>

  <h3 id="Hi_Common_XmlUtils_XmlUtil_GetFileWrappedXElement_System_Xml_Linq_XElement_System_String_System_String_System_Boolean_" data-uid="Hi.Common.XmlUtils.XmlUtil.GetFileWrappedXElement(System.Xml.Linq.XElement,System.String,System.String,System.Boolean)">
  GetFileWrappedXElement(XElement, string, string, bool)
  
  </h3>

  <div class="markdown level1 summary"><p>Wraps an XML element in a file reference element or returns it as-is.</p>
</div>
  <div class="markdown level1 conceptual"></div>

  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public static XElement GetFileWrappedXElement(this XElement src, string baseDirectory, string sourceFile, bool exhibitionOnly)</code></pre>
  </div>

  <h4 class="section">Parameters</h4>
  <dl class="parameters">
    <dt><code>src</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.xml.linq.xelement">XElement</a></dt>
    <dd><p>The source XML element to wrap</p>
</dd>
    <dt><code>baseDirectory</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
    <dd><p>The base directory for resolving paths</p>
</dd>
    <dt><code>sourceFile</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
    <dd><p>The relative file path to save the element to, or null to return the element as-is</p>
</dd>
    <dt><code>exhibitionOnly</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.boolean">bool</a></dt>
    <dd><p>See <a class="xref" href="Hi.Common.XmlUtils.IMakeXmlSource.html#Hi_Common_XmlUtils_IMakeXmlSource_MakeXmlSource_System_String_System_String_System_Boolean_">MakeXmlSource(string, string, bool)</a> for parameter description.</p>
</dd>
  </dl>

  <h4 class="section">Returns</h4>
  <dl class="parameters">
    <dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.xml.linq.xelement">XElement</a></dt>
    <dd><p>If sourceFile is null, returns the original element;
otherwise, saves the element to the specified file and returns a file reference element</p>
</dd>
  </dl>











  <a id="Hi_Common_XmlUtils_XmlUtil_GetFirstChildElement_" data-uid="Hi.Common.XmlUtils.XmlUtil.GetFirstChildElement*"></a>

  <h3 id="Hi_Common_XmlUtils_XmlUtil_GetFirstChildElement_System_Xml_Linq_XElement_" data-uid="Hi.Common.XmlUtils.XmlUtil.GetFirstChildElement(System.Xml.Linq.XElement)">
  GetFirstChildElement(XElement)
  
  </h3>

  <div class="markdown level1 summary"><p>Gets the first child element of the source XElement.</p>
</div>
  <div class="markdown level1 conceptual"></div>

  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public static XElement GetFirstChildElement(this XElement src)</code></pre>
  </div>

  <h4 class="section">Parameters</h4>
  <dl class="parameters">
    <dt><code>src</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.xml.linq.xelement">XElement</a></dt>
    <dd><p>The source XElement</p>
</dd>
  </dl>

  <h4 class="section">Returns</h4>
  <dl class="parameters">
    <dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.xml.linq.xelement">XElement</a></dt>
    <dd><p>The first child element, or null if no children exist</p>
</dd>
  </dl>











  <a id="Hi_Common_XmlUtils_XmlUtil_GetNameNoteXElementList_" data-uid="Hi.Common.XmlUtils.XmlUtil.GetNameNoteXElementList*"></a>

  <h3 id="Hi_Common_XmlUtils_XmlUtil_GetNameNoteXElementList_Hi_Common_INameNote_" data-uid="Hi.Common.XmlUtils.XmlUtil.GetNameNoteXElementList(Hi.Common.INameNote)">
  GetNameNoteXElementList(INameNote)
  
  </h3>

  <div class="markdown level1 summary"><p>Creates a list of XML elements representing the name and note properties of an INameNote object.</p>
</div>
  <div class="markdown level1 conceptual"></div>

  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public static List&lt;XElement&gt; GetNameNoteXElementList(this INameNote src)</code></pre>
  </div>

  <h4 class="section">Parameters</h4>
  <dl class="parameters">
    <dt><code>src</code> <a class="xref" href="Hi.Common.INameNote.html">INameNote</a></dt>
    <dd><p>The source INameNote object</p>
</dd>
  </dl>

  <h4 class="section">Returns</h4>
  <dl class="parameters">
    <dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.collections.generic.list-1">List</a>&lt;<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.xml.linq.xelement">XElement</a>&gt;</dt>
    <dd><p>A list of XML elements containing the name and note</p>
</dd>
  </dl>











  <a id="Hi_Common_XmlUtils_XmlUtil_GetOrDefault_" data-uid="Hi.Common.XmlUtils.XmlUtil.GetOrDefault*"></a>

  <h3 id="Hi_Common_XmlUtils_XmlUtil_GetOrDefault__1_System_Xml_Linq_XElement_System_String___0_" data-uid="Hi.Common.XmlUtils.XmlUtil.GetOrDefault``1(System.Xml.Linq.XElement,System.String,``0)">
  GetOrDefault&lt;T&gt;(XElement, string, T)
  
  </h3>

  <div class="markdown level1 summary"><p>If <code class="paramref">xpath</code> exist, return value by <code class="paramref">xpath</code>
; Otherwise, return <code class="paramref">defaultValue</code>.</p>
<p>The <code class="paramref">xpath</code> must indicates solely one <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.xml.linq.xelement">XElement</a>.</p>
</div>
  <div class="markdown level1 conceptual"></div>

  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public static T GetOrDefault&lt;T&gt;(this XElement src, string xpath, T defaultValue) where T : IConvertible</code></pre>
  </div>

  <h4 class="section">Parameters</h4>
  <dl class="parameters">
    <dt><code>src</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.xml.linq.xelement">XElement</a></dt>
    <dd><p>local root element</p>
</dd>
    <dt><code>xpath</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
    <dd><p>xpath</p>
</dd>
    <dt><code>defaultValue</code> <span class="xref">T</span></dt>
    <dd><p>default value</p>
</dd>
  </dl>

  <h4 class="section">Returns</h4>
  <dl class="parameters">
    <dt><span class="xref">T</span></dt>
    <dd><p>If <code class="paramref">xpath</code> exist, return value by <code class="paramref">xpath</code>
; Otherwise, return <code class="paramref">defaultValue</code>.</p>
</dd>
  </dl>

  <h4 class="section">Type Parameters</h4>
  <dl class="parameters">
    <dt><code>T</code></dt>
    <dd><p>type of defaultValue</p>
</dd>
  </dl>










  <a id="Hi_Common_XmlUtils_XmlUtil_MakeXmlSourceFile_" data-uid="Hi.Common.XmlUtils.XmlUtil.MakeXmlSourceFile*"></a>

  <h3 id="Hi_Common_XmlUtils_XmlUtil_MakeXmlSourceFile_Hi_Common_XmlUtils_IMakeXmlSource_System_String_System_Boolean_" data-uid="Hi.Common.XmlUtils.XmlUtil.MakeXmlSourceFile(Hi.Common.XmlUtils.IMakeXmlSource,System.String,System.Boolean)">
  MakeXmlSourceFile(IMakeXmlSource, string, bool)
  
  </h3>

  <div class="markdown level1 summary"><p>Creates an XML source file from the provided source at the specified file path.</p>
</div>
  <div class="markdown level1 conceptual"></div>

  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public static void MakeXmlSourceFile(this IMakeXmlSource src, string filePath, bool exhibitionOnly = false)</code></pre>
  </div>

  <h4 class="section">Parameters</h4>
  <dl class="parameters">
    <dt><code>src</code> <a class="xref" href="Hi.Common.XmlUtils.IMakeXmlSource.html">IMakeXmlSource</a></dt>
    <dd><p>The source that implements IMakeXmlSource interface.</p>
</dd>
    <dt><code>filePath</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
    <dd><p>The path where the XML file will be created.</p>
</dd>
    <dt><code>exhibitionOnly</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.boolean">bool</a></dt>
    <dd><p>See <a class="xref" href="Hi.Common.XmlUtils.IMakeXmlSource.html#Hi_Common_XmlUtils_IMakeXmlSource_MakeXmlSource_System_String_System_String_System_Boolean_">MakeXmlSource(string, string, bool)</a> for parameter description.</p>
</dd>
  </dl>












  <a id="Hi_Common_XmlUtils_XmlUtil_MakeXmlSourceWithRebaseFile_" data-uid="Hi.Common.XmlUtils.XmlUtil.MakeXmlSourceWithRebaseFile*"></a>

  <h3 id="Hi_Common_XmlUtils_XmlUtil_MakeXmlSourceWithRebaseFile_Hi_Common_XmlUtils_IMakeXmlSource_System_String_System_String_System_Boolean_" data-uid="Hi.Common.XmlUtils.XmlUtil.MakeXmlSourceWithRebaseFile(Hi.Common.XmlUtils.IMakeXmlSource,System.String,System.String,System.Boolean)">
  MakeXmlSourceWithRebaseFile(IMakeXmlSource, string, string, bool)
  
  </h3>

  <div class="markdown level1 summary"><p>Creates an XML representation of an object and optionally saves it to a file with path rebasing.</p>
</div>
  <div class="markdown level1 conceptual"></div>

  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public static XElement MakeXmlSourceWithRebaseFile(this IMakeXmlSource src, string baseDirectory, string relFile, bool exhibitionOnly)</code></pre>
  </div>

  <h4 class="section">Parameters</h4>
  <dl class="parameters">
    <dt><code>src</code> <a class="xref" href="Hi.Common.XmlUtils.IMakeXmlSource.html">IMakeXmlSource</a></dt>
    <dd><p>The source object to serialize</p>
</dd>
    <dt><code>baseDirectory</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
    <dd><p>The base directory for resolving paths</p>
</dd>
    <dt><code>relFile</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
    <dd><p>The relative file path to save the XML to, or null to not save to a file</p>
</dd>
    <dt><code>exhibitionOnly</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.boolean">bool</a></dt>
    <dd><p>See <a class="xref" href="Hi.Common.XmlUtils.IMakeXmlSource.html#Hi_Common_XmlUtils_IMakeXmlSource_MakeXmlSource_System_String_System_String_System_Boolean_">MakeXmlSource(string, string, bool)</a> for parameter description.</p>
</dd>
  </dl>

  <h4 class="section">Returns</h4>
  <dl class="parameters">
    <dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.xml.linq.xelement">XElement</a></dt>
    <dd><p>If relFile is null or empty, returns the XML representation of the object;
otherwise, saves the XML to the specified file and returns a file reference element</p>
</dd>
  </dl>











  <a id="Hi_Common_XmlUtils_XmlUtil_MakeXmlSource_" data-uid="Hi.Common.XmlUtils.XmlUtil.MakeXmlSource*"></a>

  <h3 id="Hi_Common_XmlUtils_XmlUtil_MakeXmlSource__1_System_Collections_Generic_IDictionary_System_String___0__System_String_System_Boolean_" data-uid="Hi.Common.XmlUtils.XmlUtil.MakeXmlSource``1(System.Collections.Generic.IDictionary{System.String,``0},System.String,System.Boolean)">
  MakeXmlSource&lt;T&gt;(IDictionary&lt;string, T&gt;, string, bool)
  
  </h3>

  <div class="markdown level1 summary"><p>Creates an XML representation of a dictionary of XML-serializable objects.</p>
</div>
  <div class="markdown level1 conceptual"></div>

  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public static XElement MakeXmlSource&lt;T&gt;(this IDictionary&lt;string, T&gt; dictionary, string baseDirectory, bool exhibitionOnly) where T : IMakeXmlSource</code></pre>
  </div>

  <h4 class="section">Parameters</h4>
  <dl class="parameters">
    <dt><code>dictionary</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.collections.generic.idictionary-2">IDictionary</a>&lt;<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a>, T&gt;</dt>
    <dd><p>The dictionary to serialize</p>
</dd>
    <dt><code>baseDirectory</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
    <dd><p>The base directory for resolving paths</p>
</dd>
    <dt><code>exhibitionOnly</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.boolean">bool</a></dt>
    <dd><p>See <a class="xref" href="Hi.Common.XmlUtils.IMakeXmlSource.html#Hi_Common_XmlUtils_IMakeXmlSource_MakeXmlSource_System_String_System_String_System_Boolean_">MakeXmlSource(string, string, bool)</a> for parameter description.</p>
</dd>
  </dl>

  <h4 class="section">Returns</h4>
  <dl class="parameters">
    <dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.xml.linq.xelement">XElement</a></dt>
    <dd><p>An XML element containing the serialized dictionary</p>
</dd>
  </dl>

  <h4 class="section">Type Parameters</h4>
  <dl class="parameters">
    <dt><code>T</code></dt>
    <dd><p>The type of objects in the dictionary, must implement IMakeXmlSource</p>
</dd>
  </dl>










  <a id="Hi_Common_XmlUtils_XmlUtil_SaveToByteArrayAsync_" data-uid="Hi.Common.XmlUtils.XmlUtil.SaveToByteArrayAsync*"></a>

  <h3 id="Hi_Common_XmlUtils_XmlUtil_SaveToByteArrayAsync_Hi_Common_XmlUtils_IMakeXmlSource_System_String_" data-uid="Hi.Common.XmlUtils.XmlUtil.SaveToByteArrayAsync(Hi.Common.XmlUtils.IMakeXmlSource,System.String)">
  SaveToByteArrayAsync(IMakeXmlSource, string)
  
  </h3>

  <div class="markdown level1 summary"><p>Asynchronously saves an XML source to a byte array.</p>
</div>
  <div class="markdown level1 conceptual"></div>

  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public static Task&lt;byte[]&gt; SaveToByteArrayAsync(this IMakeXmlSource src, string baseDirectory)</code></pre>
  </div>

  <h4 class="section">Parameters</h4>
  <dl class="parameters">
    <dt><code>src</code> <a class="xref" href="Hi.Common.XmlUtils.IMakeXmlSource.html">IMakeXmlSource</a></dt>
    <dd><p>The XML source to save</p>
</dd>
    <dt><code>baseDirectory</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
    <dd><p>The base directory for resolving paths</p>
</dd>
  </dl>

  <h4 class="section">Returns</h4>
  <dl class="parameters">
    <dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1">Task</a>&lt;<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.byte">byte</a>[]&gt;</dt>
    <dd><p>A byte array containing the serialized XML data</p>
</dd>
  </dl>











  <a id="Hi_Common_XmlUtils_XmlUtil_SetNameNote_" data-uid="Hi.Common.XmlUtils.XmlUtil.SetNameNote*"></a>

  <h3 id="Hi_Common_XmlUtils_XmlUtil_SetNameNote_Hi_Common_INameNote_System_Xml_Linq_XElement_" data-uid="Hi.Common.XmlUtils.XmlUtil.SetNameNote(Hi.Common.INameNote,System.Xml.Linq.XElement)">
  SetNameNote(INameNote, XElement)
  
  </h3>

  <div class="markdown level1 summary"><p>Sets the name and note properties of an INameNote object from an XML element.</p>
</div>
  <div class="markdown level1 conceptual"></div>

  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public static void SetNameNote(this INameNote dst, XElement src)</code></pre>
  </div>

  <h4 class="section">Parameters</h4>
  <dl class="parameters">
    <dt><code>dst</code> <a class="xref" href="Hi.Common.INameNote.html">INameNote</a></dt>
    <dd><p>The destination INameNote object to update</p>
</dd>
    <dt><code>src</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.xml.linq.xelement">XElement</a></dt>
    <dd><p>The source XML element containing the name and note values</p>
</dd>
  </dl>












  <a id="Hi_Common_XmlUtils_XmlUtil_SetOrGenerate_" data-uid="Hi.Common.XmlUtils.XmlUtil.SetOrGenerate*"></a>

  <h3 id="Hi_Common_XmlUtils_XmlUtil_SetOrGenerate__1_System_Xml_Linq_XElement_System_String___0_System_String_" data-uid="Hi.Common.XmlUtils.XmlUtil.SetOrGenerate``1(System.Xml.Linq.XElement,System.String,``0,System.String)">
  SetOrGenerate&lt;T&gt;(XElement, string, T, string)
  
  </h3>

  <div class="markdown level1 summary"><p>Sets a value at the specified XPath, creating the path if it doesn't exist.</p>
</div>
  <div class="markdown level1 conceptual"></div>

  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public static void SetOrGenerate&lt;T&gt;(this XElement src, string xpath, T value, string comment = null) where T : IConvertible</code></pre>
  </div>

  <h4 class="section">Parameters</h4>
  <dl class="parameters">
    <dt><code>src</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.xml.linq.xelement">XElement</a></dt>
    <dd><p>The source XElement</p>
</dd>
    <dt><code>xpath</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
    <dd><p>The XPath to set the value at</p>
</dd>
    <dt><code>value</code> <span class="xref">T</span></dt>
    <dd><p>The value to set</p>
</dd>
    <dt><code>comment</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
    <dd><p>Optional comment to add above the element</p>
</dd>
  </dl>


  <h4 class="section">Type Parameters</h4>
  <dl class="parameters">
    <dt><code>T</code></dt>
    <dd><p>The type of value to set</p>
</dd>
  </dl>










  <a id="Hi_Common_XmlUtils_XmlUtil_UnWrapIfFileBased_" data-uid="Hi.Common.XmlUtils.XmlUtil.UnWrapIfFileBased*"></a>

  <h3 id="Hi_Common_XmlUtils_XmlUtil_UnWrapIfFileBased_System_Xml_Linq_XElement_System_String_Hi_Common_XmlUtils_SetFileDelegate_" data-uid="Hi.Common.XmlUtils.XmlUtil.UnWrapIfFileBased(System.Xml.Linq.XElement,System.String,Hi.Common.XmlUtils.SetFileDelegate)">
  UnWrapIfFileBased(XElement, string, SetFileDelegate)
  
  </h3>

  <div class="markdown level1 summary"><p>Unwraps an XML element if it contains a file reference element.</p>
</div>
  <div class="markdown level1 conceptual"></div>

  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public static XElement UnWrapIfFileBased(this XElement src, string baseDirectory, SetFileDelegate setFileAction)</code></pre>
  </div>

  <h4 class="section">Parameters</h4>
  <dl class="parameters">
    <dt><code>src</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.xml.linq.xelement">XElement</a></dt>
    <dd><p>The source XML element that may contain a file reference</p>
</dd>
    <dt><code>baseDirectory</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
    <dd><p>The base directory for resolving paths</p>
</dd>
    <dt><code>setFileAction</code> <a class="xref" href="Hi.Common.XmlUtils.SetFileDelegate.html">SetFileDelegate</a></dt>
    <dd><p>Action to execute with the file path, or null if no file reference is found</p>
</dd>
  </dl>

  <h4 class="section">Returns</h4>
  <dl class="parameters">
    <dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.xml.linq.xelement">XElement</a></dt>
    <dd><p>If the source element contains a file reference, returns the XML content loaded from the referenced file;
otherwise, returns the original element</p>
</dd>
  </dl>












</article>

        <div class="contribution d-print-none">
        </div>


      </div>

      <div class="affix">
        <nav id="affix"></nav>
      </div>
    </main>

    <div class="container-xxl search-results" id="search-results"></div>

    <footer class="border-top text-secondary">
      <div class="container-xxl">
        <div class="flex-fill">
          <span> Copyright © 2025 <a href='https://superhightech.com.tw'>Tech Coordinate</a>. All rights reserved. <a href='https://superhightech.com.tw'>超級高科技股份有限公司</a> © 2025 版權所有 </span>
        </div>
      </div>
    </footer>
  </body>
</html>
